<template>
<div>
	<x-header> 我的抄送/传阅 <router-link to="/" slot="right"> <a class="fa fa-home fa-15x"></a> </router-link></x-header>
	<div>
		<ab-scroller noDataText="没有更多移动端可查看的抄送/传阅了" url="/bpm/carbonCopy/receiveList?inst.support_mobile_$VEQ=1" :conditions='[{key:"inst.subject_^VLK",value:"标题"}]'>
			<div slot-scope="slotScope">
			<div class="weui-cell vux-tap-active weui-cell_access"  v-for="copy in slotScope.rows">
				<div class="weui-cell__hd"></div>
				<div class="vux-cell-bd vux-cell-primary"  @click="openDetail(copy)">
					<p>
						<label class="vux-label">{{copy.nodeName}}</label>
					</p>
					<span class="vux-label-desc">{{copy.subject}}</span>
				</div>
				<div class="weui-cell__ft">
					<div>
						<x-button v-if="copy.status=='read'" mini plain >已读</x-button>
						<x-button v-if="copy.status=='unread'" mini plain type="warn">未读</x-button>
						<x-button v-if="copy.status=='reviewed'" mini plain type="warn">已审阅</x-button>
						<x-button mini type="primary" @click.native="open(copy)">查看消息</x-button>

					</div>
				</div>
			</div>
		</div>
		</ab-scroller>
	</div>
</div>
</template>

<script>

import Vue from 'vue';

export default {
	data: function () {
	  return {
		  tasks:[]
	  }
	},
	created : function(){
	},
	methods: {
		openDetail: function(copy){
			this.read(copy);
	        this.$router.push({
	            path: '/bpm/instanceDetailCopy',
	            query:{instanceId: copy.instId,nodeId:copy.nodeId,carbonId:copy.id}
	          })

		},
		 open : function(row){
			  this.read(row);
			  let url = this.__ctx+"/bpm/carbonCopy/"+row.recordId+"/record";
	 		  let post = this.baseService.get(url);
	 		 this.abTools.getResultData(post, data => {
	 			  this.$vux.alert.show({
	 			        title: '抄送/传阅消息',
	 			        content: data.content,
	 			  })
	 		  });
		  },
		  //读取消息
		  read : function(row){
			  if(row.read){
				  return;
			  }
			  let url = this.__ctx+"/bpm/carbonCopy/updateRead";
	 		  let post = this.baseService.postForm(url,{
	 			  id:row.id
	 		  });
	 		 this.abTools.getResultData(post, data => {
	 			  row.read = true;
	 		  });
		  }
	}
}
</script>
